/**
 * @description 用户请求接口
 * @author LI
 * @date 2020-11-17 15:22
 */

import { service } from '@/utils/axios'
import { Result } from '@/utils/axios/types'
import { getCodeData, getPhoneCodeData, getTrafficData, LoginData, registerData, rowsLoginData } from '@/api/sys/model/userModel'

// 登录
export function login(data: LoginData) {
  return service.request<Result<rowsLoginData>>({
    url: '/auth/login',
    method: 'post',
    data
  })
}

// 获取用户信息
export function getAccountInfo() {
  return service.request<Result<rowsLoginData>>({
    url: '/auth/getAccountInfo',
    method: 'get'
  })
}

// 注册
export function register(data: registerData) {
  return service.request<Result>({
    url: '/user/register',
    method: 'post',
    data
  })
}

// 获取验证码
export function sendEmailCode(params: getCodeData) {
  return service.request<Result>({
    url: '/email/sendEmailCode',
    method: 'get',
    params
  })
}

// 退出登录
export function logout() {
  return service.request<Result>({
    url: '/auth/logout',
    method: 'get'
  })
}

// 获取青岛手机验证码
export function sendPhoneCode(params: getPhoneCodeData) {
  return service.request<Result>({
    url: '/email/sendPhoneCode',
    method: 'get',
    params
  })
}

// 注册
export function getTraffic(params: getTrafficData) {
  return service.request<Result>({
    url: '/email/getTraffic',
    method: 'get',
    params
  })
}
